package com.bxd.baodan.fragment;

import android.view.View;
import android.widget.ImageView;

import com.google.gson.reflect.TypeToken;
import com.bxd.baodan.App;
import com.bxd.baodan.R;
import com.bxd.baodan.activity.WebViewPager;
import com.bxd.baodan.app.JsonApi;
import com.bxd.baodan.base.BaseListFragment;
import com.bxd.baodan.item.FangAnBean.DataBean.FangAnBean_;
import com.bxd.baodan.util.GlideUtil;
import com.bxd.baodan.util.NetUtil;
import com.umeng.analytics.MobclickAgent;
import com.bxd.baodan.adapter.ViewHolder;

import java.lang.reflect.Type;
import java.util.List;

/**
 * Created by lizhichao on 17/9/7.
 */

public class FangAnFragment extends BaseListFragment<FangAnBean_> {
    @Override
    protected void preDone(View v) {
        autoRefresh();
    }

    @Override
    protected int getFragmentLayout() {
        return R.layout.pull_refresh_layout_no_divider;
    }

    @Override
    protected Type getTypeToken() {
        return new TypeToken<List<FangAnBean_>>() {
        }.getType();
    }

    @Override
    protected void setUsualNetUtil() {
        netUtil = new NetUtil(getActivity(), JsonApi.EXAMPLE_LISTS);

    }

    @Override
    protected int getItemLayout() {
        return R.layout.item_fang_an;
    }

    @Override
    protected void convert(ViewHolder holder, final FangAnBean_ item) {

        GlideUtil.loadImage(getActivity(), item.image, (ImageView) holder.getView(R.id.image));


        holder.setText(R.id.title, item.title);

        holder.getView(R.id.main).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                  MobclickAgent.onEvent(App.getContext(), "v6_0_0_GH_fa_wzxq");
                openActivity(WebViewPager.class, new String[]{"startUrl"}, new String[]{item.url});
            }
        });


    }

    @Override
    protected String getArrayStr(String json_data) {
        return "list";
    }
}
